from flask import Flask, request, jsonify
from douyin_publish_spider import *
app = Flask(__name__)



@app.route('/douyin/goods/detail/desc', methods=['GET','POST'])
def process_data():
    # try:
    if request.method == 'POST':
        data = request.get_json()
        goods_url = data["goods_url"]
        # goods_url = data.get('goods_url',[])

        res = DY_XPIDER(str(goods_url))
        result_data = res.dy_creator_center_spider()
        print(goods_url)
        print(result_data)
        print(result_data)
        return result_data

    else:
        user_id = request.args["user_id"]
        res = DY_XPIDER(str(user_id))
        result_data = res.dy_creator_center_spider()
        return result_data
    # except:
    #     return {"msg":"未传参数","code":"500"}


if __name__ == '__main__':

    app.run(host='0.0.0.0',port=5009,threaded=True)
